<template>
  <router-view/>
<!--  <router-view v-slot="{ Component }">-->
<!--      <transition>-->
<!--          <keep-alive>-->
<!--              <component :is="Component">s</component>-->
<!--          </keep-alive>-->
<!--      </transition>-->
<!--  </router-view>-->
  <div id="nav">
    <router-link to="/" class="nav-bar-items">
      <div><i class="iconfont icon-index"></i></div>
      <div>首页</div>
    </router-link>
    <router-link to="/booksort" class="nav-bar-items">
      <div><i class="iconfont icon-category"></i></div>
      <div>分类</div>
    </router-link>
    <router-link to="/shopcart" class="nav-bar-items">
      <div class="icon" style="z-index: 9">
        <van-badge :content="$store.state.acountCart" max="99">
          <i class="iconfont icon-gouwuche"></i>
        </van-badge>
      </div>
      <div>购物车</div>
    </router-link>
    <router-link to="/user"  class="nav-bar-items">
      <div><i class="iconfont icon-wode"></i></div>
      <div>用户中心</div>
    </router-link>
  </div>
</template>
<script>
  import {useStore} from 'vuex'
  import {onMounted} from 'vue'
  export  default {

    setup(){
      const store = useStore();
      onMounted(()=>{
        store.dispatch('updateCart')
      })
    }
  }
</script>
<style lang="scss">
  @import "assets/css/base.css";
  @import "assets/css/iconfont.css";

  .icon{
    padding: 5px;
  }
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  display: flex;
  background-color: aliceblue;
  position: fixed;
  left: 0;
  right:  0;
  bottom: 0;
  box-shadow: 0 -3px  1px rgba(100,100,100,0.1);
  a {
    color: var(--color-text);

    &.router-link-exact-active {
      color: #42b983;
    }
  }
  .nav-bar-items{
    flex: 1;
    text-align: center;
    height: 50px;
    font-size: var(--font-size);
  }
  .nav-bar-items>div>i{
    height: 24px;
    width: 24px;
    margin-top: 3px;
    display: inline-block;
    vertical-align: middle;
  }
}
  .details{
    img{
      height: auto;
      width: 100%;
    }
  }
  .bookinfo{
    .van-card__title{
      font-size: 18px;
    }

  }
</style>
